<template>
<view class="page-all">
	<Header title="选择学校" bgColor="#fff" :leftIconSize="20" ></Header>
	<view class="search-content">
		<view class="left">
			<uv-search placeholder="学校名称" bgColor="#fff" v-model="keyword" :showAction="false"></uv-search>
		</view>
		<view class="screen-icon" @click="showScreen">
			<image src="@/static/image/index/icon2.png" mode="widthFix"></image>
		</view>
	</view>
	<!--学校列表-->
	<view class="school-list">
		<uv-radio-group v-model="radiovalue">
			<view class="container">
				<view class="item"  v-for="(item,index) in dataList" :key="index">
					<view class="radio">
						<uv-radio :name="item.id" >
							<template #default><view class="name">{{item.name}}</view></template>
						</uv-radio>
					</view>
				</view>
			</view>
			
		</uv-radio-group>
	</view>
	<!--筛选弹层-->
	<uv-popup ref="popup" @change="change" :closeable="true">
		<view class="popup-title">筛选</view>
		<view class="popup-content">
			<view class="popup-title-row">
				<text>办学性质</text>
			</view>
			<view class="popup-con-row">
				<view class="item" :class="{actived:natureCurren==item.name}" v-for="(item,index) in natureList" :key="index" @click="natureCurren=item.name">{{item.name}}</view>
			</view>
			<view class="popup-title-row">
				<text>地区</text>
			</view>
			<view class="popup-con-row">
				<view class="item" :class="{actived:cityCurren==item.name}" v-for="(item,index) in cityList" :key="index" @click="cityCurren=item.name">{{item.name}}</view>
			</view>
			<view class="bottom-box" @click.stop>
			  <button class="sure-button" @click.stop="popupSubmit()">确认</button>
			</view>
		</view>
	</uv-popup>
	<view class="check-bottom-box" @click.stop>
	  <button class="sure-button" @click.stop="submit()">确认</button>
	</view>
	
</view>
</template>

<script setup>
	import {reactive, ref} from 'vue'
	import config from "@/common/config";
	let imgMinioPath = ref(config.IMG_MINIO_PATH);
	const radiovalue = ref('')
	const cityCurren=ref('省直')  //选中城市
	const natureCurren = ref('民办')  //选中的学校性质
	const dataList=reactive([
		{id:'1',name:'东北师范大学附属中学'},
		{id:'2',name:'长春市实验中学'},
		{id:'3',name:'长春市第二实验中学长春市第二实验中学（含原南校）'},
	])
	
	const natureList = reactive([
		{name:'民办'},
		{name:'公办'},
		{name:'其他'}
	])
	
	const cityList=reactive([
		{name:'省直',code:''},
		{name:'长春市',code:''},
		{name:'吉林市',code:''},
		{name:'四平市',code:''},
		{name:'白城市',code:''},
		{name:'松原市',code:''},
		{name:'辽源市',code:''},
		{name:'白山市',code:''},
		{name:'通化市',code:''},
		{name:'延吉市',code:''}
	])
	
	//返回把选中学校数据传回
	function submit(){
		uni.navigateBack({
		  delta: 1,
		  success: function(res) {
			let currentObj = dataList.filter((item=>item.id == radiovalue.value))
		    uni.$emit('schoolData', currentObj)
		  }
		})
	}
	
	let popup = ref()
	//显示筛选弹层
	function showScreen(){
		popup.value.open('bottom')
	}
	
	function popupSubmit(){
		popup.value.close()
	}
</script>

<style scoped>
	.bottom-box{
		padding: 0;
	}
	
</style>